/********************************************************************
	created:	2008/09/30
	created:	30:9:2008   18:19
	filename: 	h:\SimoneEngine\qianye\src\qylib\filesys\qyZipPackage.h
	author:		Xiong Jiayu
	copyright:  
	purpose:	
*********************************************************************/
#pragma once

#ifndef __QYZIPPACKAGE_H__
#define __QYZIPPACKAGE_H__

#include <unzip.h>
#include "../memsys/qyString.h"
#include "../memsys/qyArray.h"
#include "qyZipFileFilter.h"
#include "qyZipEntry.h"

/*
===========================================
class qyZipPackage
===========================================
*/
class qyZipPackage
{
public:
	typedef std::vector<qyString>	PathList;
public:
							qyZipPackage();
	virtual					~qyZipPackage();

	bool					SetPackageFile( const qyString &path );
	const qyString &		GetPackageFile( void ) const;

	bool					OpenReadFile( qyFile &file, const qyString &relativePath );
	
	void					ParseTableOfContents();

	PathList				GetFileListInPktDir( const qyString &dirInZip );

	PathList				GetDirListInPktDir( const qyString &dirInZip );

protected:
	void					Release();
	void					_AddEntry( const qyString &path );

protected:
	qyString				m_path;
	unzFile					m_zipHandle;
	qyZipFileFilter			m_zipFilter;	
	qyZipEntry				m_rootEntry;
};

QY_INLINE const qyString & qyZipPackage::GetPackageFile() const
{
	return m_path;
}

#endif
